package com.jyhs.maven.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDKProxyHandler implements InvocationHandler {


    Object target;

    public void setTarget(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long start = System.currentTimeMillis();
        Object invoke = method.invoke(target, args);
        long end = System.currentTimeMillis();
        System.out.println("jdk动态代理：class:"+target.getClass().getName() +",method:" + method.getName() + " cost time:" + (end - start) + "ms");
        return invoke;
    }
}
